import org.jboss.netty.buffer.ChannelBuffer;

import util.ChannelBufferUtil;

import data.ISerializable;


public class DataPlayerClient implements ISerializable {
	public String name;
	
	public int country;
	public int profession;
	public int sex;
	public int level;
	public int hpMax;
	public int mpMax;
	
	public int attack;
	public int speed;
	
	public int defense;
	public int defenseBreak;
	
	public int dodge;
	public int hit;
	
	public int critical;
	public int criticalBreak;	
	
	public int[] skills;
	public int[] equips;	
	
	@Override
	public void serialize(ChannelBuffer buf) {
		ChannelBufferUtil.writeString(buf, name);
		
		buf.writeInt(profession);
		buf.writeInt(sex);
		buf.writeInt(level);
		buf.writeInt(hpMax);
		buf.writeInt(mpMax);
		
		buf.writeInt(attack);
		buf.writeInt(speed);
		
		buf.writeInt(defense);
		buf.writeInt(defenseBreak);
		
		buf.writeInt(dodge);
		buf.writeInt(hit);
		
		buf.writeInt(critical);
		buf.writeInt(criticalBreak);
		
		buf.writeInt(country);
		
		buf.writeInt(skills.length);
		for (int skill:skills) {
			buf.writeInt(skill);
		}
		
		buf.writeInt(skills.length);
		for (int equip:equips) {
			buf.writeInt(equip);
		}
	}
	
	@Override
	public void unserialize(ChannelBuffer buf) {
		String str = ChannelBufferUtil.readString(buf);
		name = str;
		
		profession = buf.readInt();
		sex = buf.readInt();

		level = buf.readInt();
		hpMax = buf.readInt();
		mpMax = buf.readInt();
		
		attack = buf.readInt();
		speed = buf.readInt();
		
		defense = buf.readInt();
		defenseBreak = buf.readInt();
		
		dodge = buf.readInt();
		hit = buf.readInt();
		
		critical = buf.readInt();
		criticalBreak = buf.readInt();
		
		country =  buf.readInt();		
		
		int size = buf.readInt();
		skills = new int[size];
		for (int i = 0; i < size; i++) {
			skills[i] = buf.readInt();
		}
		
		size = buf.readInt();
		equips = new int[size];
		for (int i = 0; i < size; i++) {
			equips[i] = buf.readInt();
		}
		
		buf.readInt(); //score
		buf.readInt(); //ranking
		buf.readInt(); //grade;
	}

}
